{% extends "admin/layout.html" %}

{% block head %} 
<title>{{ _(config["WEBSITE_NAME"]) }} - {{ _("Control Panel") }}</title>
{% if session["direction"] =="rtl" %}
  <style type="text/css">
    .month {
      float: right !important;
    }
    .count {
      float: left !important;
    }
  </style>
{% endif %}
{% endblock %}

{% block body %}
<div class="right_col" role="main">
  <div class="">
    <div class="page-title">
      <div class="title_left">
        <h3>{{ _("Home") }}</h3>
      </div>
    </div>
    <div class="clearfix"></div>
    <div class="row">
        <div class="row top_tiles" style="margin: 10px 0;">
          <div class="col-md-3 tile">
            <span>{{ _("Total Users") }}</span>
            <h2>{{ users_num }}</h2>
            <span class="sparkline_two" style="height: 160px;">
              <canvas style="display: inline-block; width: 196px; height: 40px; vertical-align: top;" width="196" height="40"></canvas>
            </span>
          </div>
          <div class="col-md-3 tile">
            <span>{{ _("Total Wiki pages") }}</span>
            <h2>{{ wiki_posts_num }}</h2>
            <span class="sparkline_two" style="height: 160px;">
              <canvas style="display: inline-block; width: 196px; height: 40px; vertical-align: top;" width="196" height="40"></canvas>
            </span>
          </div>
          <div class="col-md-3 tile">
            <span>{{ _("Total Queue Posts") }}</span>
            <h2>{{ queue_posts_num }}</h2>
            <span class="sparkline_two" style="height: 160px;">
              <canvas style="display: inline-block; width: 196px; height: 40px; vertical-align: top;" width="196" height="40"></canvas>
            </span>
          </div>
        </div>
        <div class="clearfix"></div>
        <div class="col-md-4 col-xs-12 widget widget_tally_box">
          <div class="x_panel ui-ribbon-container" style="height: 300px;">
            <div class="x_title">
              <h2>{{ _ ("CPU Usage") }}</h2>
              <div class="clearfix"></div>
            </div>
            <div class="x_content">
              <div style="text-align: center; margin-bottom: 20px">
                <span class="chart" data-percent="{{ cpu_percent() }}">
                 <span class="percent">{{ cpu_percent() }}</span>
                 <canvas height="110" width="110"></canvas>
                </span>
              </div>
              <div>
                <ul class="list-inline widget_tally">
                  <li>
                    <p>
                      <span class="month">{{ _("Cores") }}: </span>
                      <span class="count">{{ cpu_count() }}</span>
                    </p>
                  </li>
                  <li>
                    <p>
                      <span class="month">{{ _("Processor") }}: </span>
                      <span class="count">{{ machine() }}</span>
                    </p>
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>
        <div class="col-md-4 col-xs-12 widget widget_tally_box">
          <div class="x_panel ui-ribbon-container" style="height: 300px;">
            <div class="x_title">
              <h2>{{ _("RAM Usage") }}</h2>
              <div class="clearfix"></div>
            </div>
            <div class="x_content">
              <div style="text-align: center; margin-bottom: 20px">
                <span class="chart" data-percent="{{ virtual_memory().percent }}">
                  <span class="percent">{{ virtual_memory().percent }}</span>
                  <canvas height="110" width="110"></canvas>
                </span>
              </div>
              <div>
                <ul class="list-inline widget_tally">
                  <li>
                    <p>
                      <span class="month">{{ _("Total Memory Size") }}: </span>
                      <span class="count">{{ convert_size(virtual_memory().total) }}</span>
                    </p>
                  </li>
                  <li>
                    <p>
                      <span class="month">{{ _("Used") }}: </span>
                      <span class="count">{{ convert_size(virtual_memory().used) }}</span>
                    </p>
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>
        <div class="col-md-4 col-xs-4 widget widget_tally_box">
          <div class="x_panel ui-ribbon-container" style="height: 300px;">
            <div class="x_title">
              <h2>{{ _("Disk Usage") }}</h2>
              <div class="clearfix"></div>
            </div>
            <div class="x_content">
              <div style="text-align: center; margin-bottom: 20px">
                <span class="chart" data-percent="{{ disk_usage('/').percent }}">
                  <span class="percent">{{ disk_usage("/").percent }}</span>
                  <canvas height="110" width="110"></canvas>
                </span>
              </div>
              <div>
                <ul class="list-inline widget_tally">
                  <li>
                    <p>
                      <span class="month">{{ _("Total Disk Size") }}: </span>
                      <span class="count">{{ convert_size(disk_usage("/").total) }}</span>
                    </p>
                  </li>
                  <li>
                    <p>
                      <span class="month">{{ _("Used") }}: </span>
                      <span class="count">{{ convert_size(disk_usage("/").used) }}</span>
                    </p>
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>
        <div class="col-md-12 col-sm-12 col-xs-12">
          <div class="x_panel">
            <div class="x_title">
              <h2>{{ _("Adminstrators") }}</h2>
              <ul class="nav navbar-right">
                <li>
                  <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                  </a>
                </li>
              </ul>
              <div class="clearfix"></div>
            </div>
            <div class="x_content">
              <table class="table">
                <thead>
                  <tr>
                    <th>#</th>
                    <th>{{ _("Username") }}</th>
                    <th>{{ _("Email") }}</th>
                    <th>{{ _("Action") }}</th>
                  </tr>
                </thead>
                <tbody>
                  {% for num in range(len(admins)) %}
                    <tr>
                      <th scope="row">{{ num }}</th>
                      <td>{{ admins[num].username }}</td>
                      <td>{{ admins[num].email }}</td>
                      <td>
                        <form method="GET" action="{{ url_for('admin.users_config') }}">
                          {% if admins[num].privilege != "admin" %}
                            <input type="submit" name="submit" class="btn btn-primary btn-xs" value="{{ _('Promote') }}">
                          {% else %}
                            {% if session.current_user["id"] != admins[num].Id %}
                              <input type="submit" name="submit" class="btn btn-info btn-xs" value="{{ _('Demote') }}">
                            {% endif %}
                          {% endif %}
                          {% if session.current_user["id"] != admins[num].Id %}
                            <input type="submit" name="submit" class="btn btn-danger btn-xs" value="{{ _('Delete') }}">
                          {% endif %}
                          <input type="hidden" name="id" value="{{ admins[num].Id }}">
                        </form>
                      </td>
                    </tr>
                  {% endfor %}
                </tbody>
              </table>
            </div>
          </div>
        </div>
    </div>
</div>
{% endblock %}